package libtool65.o65;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.LinkedList;
import java.util.List;

public class RelocationTable {
	List<Relocation> relocations = new LinkedList<Relocation>(); 

	public void read(InputStream file, Mode mode) throws IOException, UnknownRelocationTypeException {
		int current_offset = -1;
		relocations.clear();
		while (true)
		{
			Relocation relocation = new Relocation();
			relocation.read(file, mode);
			if (relocation.isEmpty())
				break;
			current_offset = relocation.addOffset(current_offset);
			relocations.add(relocation);
		}
	}

	public void dumpInfo(PrintStream out) {
		for (Relocation relocation : relocations)
		{
			relocation.dumpInfo(out);
		}
		
	}

	public List<Relocation> toList() {
		return relocations;
	}

}
